package com.sayice.robotconflict.game.object.logic;

import java.util.function.BiPredicate;

/**
 * 比较操作符
 *
 * @author shubing
 */
public enum CompareOperator {
    EQ((a, b) -> a.compareTo(b) == 0),
    GT((a, b) -> a.compareTo(b) > 0),
    LT((a, b) -> a.compareTo(b) < 0);
    
    private final BiPredicate<Comparable, Comparable> operator;
    
    CompareOperator(BiPredicate<Comparable, Comparable> operator) {
        this.operator = operator;
    }
    
    public <T extends Comparable<T>> boolean apply(T a, T b) {
        return operator.test(a, b);
    }
}
